import { nextTick } from "../observe/next-tick";
import { mergeOptions } from "../options";
import { initExtend } from "./extend";

export function initGlobalApi(Vue) {
    Vue.options = Object.create(null);
    Vue.options._base = Vue;
    initExtend(Vue);

    Vue.mixin = function (options) {
        this.options = mergeOptions(this.options, options);
    }
    Vue.options.components = {}

    Vue.component = function (name, definition) {
        if (!definition.name) {
            definition.name = name;
        }
        definition = this.options._base.extend(definition);
        this.options.components[name] = definition;
    }

    Vue.nextTick = nextTick;
}